package com.qianzhou.sqlSession;

import com.qianzhou.config.XMLConfigBuilder;
import com.qianzhou.pojo.Configuration;
import com.qianzhou.sqlSession.impl.DefaultSqlSessionFactory;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

/**
 * @ClassName SqlSessionFactoryBuild
 * @Description TODO
 * @Author zhouqian
 * @Date 2022/1/15 8:24 PM
 * @Version 1.0
 */

public class SqlSessionFactoryBuild {
    public static SqlSessionFactory build(InputStream in) throws PropertyVetoException, DocumentException {
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(in);
        SqlSessionFactory sqlSessionFactory = new DefaultSqlSessionFactory(configuration);
        return sqlSessionFactory;
    }
}
